package com.gpnu.crm.web.controller;

import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.gpnu.crm.query.QueryObject;
import com.gpnu.crm.service.IPermissionService;
import com.gpnu.crm.util.JSONResult;

@Controller
@RequestMapping({"permission"})
public class PermissionController {
	@Autowired
	  private IPermissionService permissionService;
	  
	  @RequestMapping({"reload"})
	  @ResponseBody
	  public Object reload() {
	    this.permissionService.reload();
	    return new JSONResult();
	  }
	  
	  @RequiresPermissions(value = {"权限列表", "permission:list"}, logical = Logical.OR)
	  @RequestMapping({"list"})
	  public String list(@ModelAttribute("qo") QueryObject qo, Model model) {
	    model.addAttribute("pageInfo", this.permissionService.query(qo));
	    return "permission/list";
	  }
}
